advanced JS and Async log:

function greet(name) {
  return "Hello, " + name + "!";
}

console.log(greet("Naomi"));
// Output: Hello, Naomi!



EMCASCRIPT:
const greet = (name) => {
  return "Hello, " + name + "!";
};

console.log(greet("Asiqur"));
// Output: Hello, Asiqur!


function greet(name) { 
GOES TO
const greet = (name) => {

 While you can use let with arrow function, const may be a better fit since functions shouldn't change after being defined.

 you can implicitly return your values without using the return keyword.


const forceEquation = (mass, acceleration) => {
  return mass * acceleration;
}

console.log(forceEquation(3, 4));


for (let i = 99; i > 0; i--) {
  console.log(` ${i} bottles of pop on the wall`);
  console.log(` ${i} bottles of pop`);
  console.log("take one down, pass it around");
  console.log(`${i-1} bottles of pop on the wall`);
  console.log();
}

There is also writing in the code with `` to show a variable directly instead of string + and or conversion

interation over each letter of a string:
const name = "dumbo";

for (let letter of name) {
  console.log(letter);
}

/* Output:
d
u
m
b
o
*/

or over the objects in a array

const boroughs = ["brooklyn", "manhattan", "the bronx", "queens", "staten island"];

for (let borough of boroughs) {
  console.log(borough);
}

/*
Output:
brooklyn
manhattan
the bronx
queens
staten island
*/

or in objects
const person = {
  name: "Austin",
  age: 29,
  occupation: "musician"
}

for (let info in person) {
  console.log(person[info]);
}

/*
Output:
Austin
29
musician
*/

for (let song of fiveMostStreamedSongs) {
  console.log(song.title);
  console.log(song.artist);
  console.log(song.streams);
}


ARRAYS The spread operator lets you "unpack" items out of collections
we use three ... periods on the left side of the array name.

const groceryList = ["apples", "bananas", "milk", "eggs"];
const householdItems = ["paper towels", "dish soap", "toothpaste"];
const combinedList = [...groceryList, ...householdItems];

console.log(combinedList);

REST OPERATOR
We can also use those same three dots to "pack" items into arrays and objects.

The rest operator collects zero or more items into objects or arrays, that can be used for things like:

Defining functions with zero or more parameters.
Help with destructuring arrays and objects.
If we're defining a function but aren't sure how many arguments it should take, we can use the rest operator:

const packGroceries = (...items) => {
  return items;
}

const packedGroceries = packGroceries("apples", "bananas", "milk");
const morePackedGroceries = packGroceries("eggs", "bread");

console.log(packedGroceries);
console.log(morePackedGroceries);
/*
Output:
[ 'apples', 'bananas', 'milk' ]
[ 'eggs', 'bread' ]
*/

FULLY DEFINING AND LOGGING AN ARRAY
// Define object here 💖
const goodreadsInfo = {
  currentlyReading: [
    {
      title: "name1",
      author: "author1"
    }
  ],

  wantToRead: [
    {
      title: "name2",
      author: "author2"
    }
  ]
}
// Define addBooks() function here 💖
const addNewBooks = (books, additionalBookObjects) => {
  return [...books, ...additionalBookObjects];
};
// Define showGoodreadsInfo() function here 💖
goodreadsInfo.currentlyReading = addNewBooks(goodreadsInfo.currentlyReading,
[
    {
      title: "name3",
      author: "author3"
    }
  ]);

const showGoodreadsInfo = (info) => {
  const { currentlyReading, wantToRead } = info;

  console.log("Currently Reading:");
  for (let book of currentlyReading) {
    console.log(`${book.title} by ${book.author}`);
  }

  console.log("\nWant to Read:");
  for (let book of wantToRead) {
    console.log(`${book.title} by ${book.author}`);
  }
};

showGoodreadsInfo(goodreadsInfo);





































